package com.jaychan.resource.server.com.jaychan.resource.server.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Jaychan tanjiecheng@borche.cn
 * @Date 2022/1/5 13:41
 */

@RestController
public class HelloController {

    /**
     * 无权限拦截，认证成功都可以访问
     */
    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }


    /**
     * Role_Admin角色才可以访问
     */
    @GetMapping("/admin")
    @PreAuthorize("hasRole('ROLE_admin')")
    public String admin(){
        return "admin";
    }



}
